/**
 * 
 */
package featureautomate.structure;

import java.util.ArrayList;

import org.eclipse.xtext.xbase.XExpression;

/**
 * @author D.Abdelali
 *
 */
public class State {
	
	private String name;
	private ArrayList<Transition> transitions;
	private String action;
	
	/**
	 * @param name
	 */
	public State(String name) {
		transitions = new ArrayList<>();
		this.name = name;
		
	}
	
	
	/**
	 * @param name
	 * @param transitions
	 * @param action
	 */
	public State(String name, ArrayList<Transition> transitions,
			String action) {
		this.name = name;
		this.transitions = transitions;
		if(action== null)
			action="";
		this.action = action;
	}


	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the transitions
	 */
	public ArrayList<Transition> getTransitions() {
		return transitions;
	}
	/**
	 * @param transitions the transitions to set
	 */
	public void setTransitions(ArrayList<Transition> transitions) {
		this.transitions = transitions;
	}
	/**
	 * @return the action
	 */
	public String getAction() {
		return action;
	}
	/**
	 * @param action the action to set
	 */
	public void setAction(String action) {
		this.action = action;
	}
	
	public State clone(){
		ArrayList<Transition> ttmp = new ArrayList<>();
		for(Transition t : transitions){
			ttmp.add(new Transition(t.getEvent().clone(), t.getState()));
		}
		return new State(name,transitions,action);
	}

}
